package cjgl.service;

import java.util.List;

import cjgl.dao.StudentDAO;
import cjgl.entity.Student;

public class StudentService {
	private StudentDAO studentDAO = new StudentDAO();

	public Student findById(Integer id) {
		return studentDAO.findById(id);
	}

	public List<Student> findAll() {
		return studentDAO.findAll();
	}

	public void delete(Integer id) {
		studentDAO.delete(id);
	}
	
	public void save(Student student) {
		Integer id = student.getId();
		if(id==null) {
			studentDAO.insert(student);
		}else{
			studentDAO.update(student);
		}
	}
	
	public void delete(Student student) {
		studentDAO.delete(student.getId());
	}
	
	public Student findByUsernameAndPassword(String username, String password) {
		return studentDAO.findByUsernameAndPassword(username,password);
	}

	public List<Student> findByTbClassId(Integer id) {
		return studentDAO.findByTbClassId(id);
	}

	
}
